<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/common/head.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="UTF-8">
		<title>步骤管理</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="${resource }/css/bootstrap.css" />
		<script src="${resource }/js/jquery-2.1.1.min.js"></script>
		<script src="${resource }/js/jquery.form.js"></script>
		<script src="${resource }/js/bootstrap.min.js?v=3.4.0"></script>
	</head>

	<body>
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-md-12">
				<h1 class="page-header">
                          	流程管理 <small>步骤编辑</small>
                     </h1>
			</div>
		</div>
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-md-12">
				<!-- 用户列表--bootstrap高级表格使用 -->
				<div class="panel panel-default">
					<div class="panel-heading">
						步骤编辑
					</div>
					<div class="panel-body">
						<!--table-responsive响应式表格，会自动添加滚动条-->
						<div class="table-responsive">
							<a href="show.do?id=${step.workflowId}"><input class="btn btn-success" type="button" value="返回上一步"></a>
							<form action="editsave.do" method="post" id="editForm">
								<table class="table">
									<tr>
										<td>编号</td>
										<td><input name="id" type="text" value="${step.id}" readonly="readonly">
											<input name="workflowId" type="hidden" value="${step.workflowId}">
										</td>
									</tr>
									<tr>
										<td>步骤</td>
										<td><input name="stepName" id="stepName" type="text" value="${step.stepName}"></td>
									</tr>
									<tr>
										<td>详情</td>
										<td><textarea name="stepInfo">${step.stepInfo}</textarea></td>
									</tr>
									<tr>
										<td>审核人</td>
										<td>
											<select name="userId">
											<c:choose>
												<c:when test="${not empty step.userId}">
													<option value="${step.userId}">${step.user.userName}</option>
												</c:when>
												<c:otherwise>
													<option value="">无</option>
												</c:otherwise>
											</c:choose>  
												<c:forEach items="${ulist}" var="user">
													<option value="${user.id}">${user.userName}</option>
												</c:forEach>
											</select>
										</td>
									</tr>

								</table>
								<input type="submit" value="保存" class="btn btn-success" onclick="return okedit()">
							</form>
						</div>
					</div>
				</div>
				<!--表格结束 -->
			</div>
		</div>

		<script>
			function okedit() {
				var stepName = document.getElementById("stepName").value;
				if(stepName != null && stepName != "") {
					return true;
				} else {
					alert("名称不能为空哦！");
					return false;
				}
			}
			//修改操作，提交
			$(function() {
				 // 1.基本参数设置 
			    var eidtos = { 						
			        type: 'POST',     // 设置表单提交方式
			        dataType: 'json', 
			        url: "editsave.do",    // 设置表单提交URL,默认为表单Form上action的路径
			        success: function(responseText, statusText, xhr, $form){    // 成功后的回调函数
			            if (responseText!="0") {
			                window.location.href="show.do?id="+responseText;
			                /* 成功后的操作 */
			            } else {
			                alert("操作失败!");    // 成功访问地址，并成功返回数据，由于不符合业务逻辑的失败
			            }
			        },  
			        error: function(xhr, status, err) {            
			            alert("请求失败!");    // 访问地址失败，或发生异常没有正常返回
			        },
			        clearForm: true,    // 成功提交后，清除表单填写内容
			        resetForm: true    // 成功提交后，重置表单填写内容
			    }; 
			    // 2.绑定ajaxSubmit()
			    $("#editForm").submit(function(){     // 提交表单的id
			        $(this).ajaxSubmit(eidtos); 
			        return false;   //防止表单自动提交
			    });
			});
		</script>
	</body>

</html>